﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SPMS.Log.Core;

namespace SPMS.Log.Utility
{
    /// <summary>
    /// 空白同步上下文
    /// </summary>
    /// <remarks>用于提供空白同步上下文的实现</remarks>
    /// <history>
    /// [zanezeng]               2010/1/14 9:09    创建
    /// </history>
    public sealed class NullSynchronizationContext : ISynchronizationContext
    {
        #region ---Constructor

        /// <summary>
        /// 初始化类型<see cref="NullSynchronizationContext"/>的新实例
        /// </summary>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]               2010/1/14 9:11    创建
        /// </history>
        private NullSynchronizationContext()
        {
        }

        #endregion

        #region ---ISynchronizationContext

        /// <summary>
        /// 根据给定的状态对象创建同步区域
        /// </summary>
        /// <param name="state">用于创建同步区域的状态对象</param>
        /// <returns>同步区域凭证。调用同步区域凭证的Dispose方法，则释放同步区域。</returns>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]               2010/1/14 9:05    创建
        /// </history>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]               2010/1/14 9:09    创建
        /// </history>
        public IDisposable Synchronize( object state )
        {
            //返回空引用
            return null;
        }

        #endregion

        #region ---Property

        /// <summary>
        /// 获得空白同步上下文的默认实现
        /// </summary>
        /// <value>空白同步上下文的默认实现</value>
        /// <remarks></remarks>
        /// <history>
        /// [zanezeng]               2010/1/14 9:11    创建
        /// </history>
        public static NullSynchronizationContext Default
        {
            get
            {
                return DEFAULT_INSTANCE;
            }
        }

        #endregion

        #region ---Field

        /// <summary>
        /// 默认实例
        /// </summary>
        private static readonly NullSynchronizationContext DEFAULT_INSTANCE = new NullSynchronizationContext();

        #endregion
    }
}
